def partition(numbers, number): # DO NOT modify this line 
    smaller=[]
    larger_or_equal=[]
    for x in numbers:
        if x < number:
            smaller.append(x)
        else:
            larger_or_equal.append(x)
    numbers[:]=smaller+[number]+larger_or_equal
    return len(smaller)

    return numbers# You can modify or delete this line

# === DO NOT modify the code below ===
def main():
    numbers = [ eval(x) for x in input().split() ]
    x = eval(input())
    index = partition(numbers, x)
    print(" ".join(map(str,numbers)))
    print(index)
    
if __name__ == "__main__":
    main()
# === DO NOT modify the code above ===